package com.anche.demo.excel;

import com.alibaba.excel.EasyExcel;

import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @ClassName: EasyExcelUtil
 * @Description: TODO
 * @date: 2023/2/8 17:35
 * @Auther: hey
 */
public class EasyExcelUtil {
    public static <T> void writeExcelWithModel(OutputStream outputStream, Class<T> clazz, Map<Integer,String[]> dropDownMap) throws IOException {
        List<SimpleExcelTest.TestVO>ls=new ArrayList<>();
        for (int i = 0; i < 3; i++) {
            SimpleExcelTest.TestVO tess=new SimpleExcelTest.TestVO();
            tess.setAge(i);
            tess.setName("zhang"+i);
            tess.setSchool("school"+i);
            ls.add(tess);
        }
        EasyExcel.write(outputStream, clazz).registerWriteHandler(new TitleHandler(dropDownMap)).sheet("sheet1").doWrite(ls);
    }
}